package com.xzmzhp.dao.cosmetic;

import com.xzmzhp.dao.cosmetic.SQL.CosmeticSQL;
import com.xzmzhp.pojo.cosmetic.Cosmetic;
import com.xzmzhp.pojo.cosmetic.CosmeticVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author 宋雪
 * @Date: 2020/11/15 19:16
 * @Description: 化妆品表数据操作类
 */
@Repository
public interface CosmeticMapper {
    /**
     * 添加化妆品
     *
     * @param cosmetic 化妆品信息
     * @return Integer
     */
    @Insert("insert into cosmetic(cosmetic_name,cosmetic_type_id,cosmetic_date,cosmetic_price,expiry_date,cosmetic_number,remark1)values(#{cosmeticName},#{cosmeticTypeId},#{cosmeticDate},#{cosmeticPrice},#{expiryDate},#{cosmeticNumber},#{remark1})")
    Integer addCosmetic(Cosmetic cosmetic);

    /**
     * 根据id删除化妆品
     *
     * @param id 好化妆品id
     * @return Integer
     */
    @Delete("delete from cosmetic where cosmetic_id=#{id}")
    Integer deleteCosmetic(@Param("id") Integer id);

    /**
     * 更新化妆品信息
     *
     * @param cosmetic 化妆品信息
     * @return Integer
     */
    @UpdateProvider(type = CosmeticSQL.class, method = "updateCosmetic")
    Integer updateCosmetic(Cosmetic cosmetic);

    /**
     * 查询全部化妆品信息
     *
     * @return List
     */
    @Select("select * from cosmetic_view group by expiry_date,cosmetic_id")
    List<CosmeticVO> selectCosmeticAll();

    /**
     * 根据条件查询化妆品信息
     *
     * @param cosmeticTypeId 化妆品类型id
     * @param cosmeticName   化妆品名称
     * @param maxPrice       价格上限
     * @param minPrice       价格下限
     * @param remark1        化妆品状态
     * @return
     */
    @SelectProvider(type = CosmeticSQL.class, method = "findCosmeticByParam")
    List<CosmeticVO> selectCosmeticByParam(@Param("cosmeticTypeId") Integer cosmeticTypeId, @Param("cosmeticName") String cosmeticName, @Param("maxPrice") BigDecimal maxPrice,
                                           @Param("minPrice") BigDecimal minPrice, @Param("remark1") String remark1);

    /**
     * 根据id查询化妆品信息
     *
     * @param id 化妆品id
     * @return 化妆品表数据操作类
     */
    @Select("select * from cosmetic_view where cosmetic_id=#{id}")
    CosmeticVO selectCosmeticById(@Param("id") Integer id);

}
